package com.yan.thread;

/**
 * @author taoge
 * @Date 2024/8/7 16:17
 * @Description 线程合并 join();
 */
public class ThreadDemo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(new MyTask8(), "线程A");
        t1.start();
        for (int i = 0; i < 50; i++) {
            System.out.println(Thread.currentThread().getName() + "--" +i);
            if(i==6){
                t1.join();
            }
        }
    }
}

class MyTask8 implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 30; i++) {
            System.out.println(Thread.currentThread().getName() +"--" + i);
        }
    }
}
